/**
 * 
 */
package com.flux.tms.tm${bean.numMain}srv.t${bean.numMain}${bean.numSub}.impl.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Repository;

import com.flux.tms.tm${bean.numMain}srv.t${bean.numMain}${bean.numSub}.${detail.javaFlieName}CVal;
import com.flux.scev6.dbopr.BaseDao;
import com.flux.scev6.login.model.LoginInfoObj;

/**
 * 
 * T${bean.numMain}${bean.numSub} ${bean.notesMain} -- ${detail.subName}   -- srv 基础数据   DAO 定义
 * 
 * T${bean.numMain}${bean.numSub} ${detail.subName}
 * 
 * <p>
 * 创建时间：${bean.dayTime}
 * <p>
 * 
 * <p>
 * 修改时间：${bean.dayTime}
 * <p>
 * 
 * @author ${bean.author}
 * 
 * @version V1.0.0
 *
 */
@Repository
public class ${detail.javaFlieName}Dao extends BaseDao {

	/**
	 * V100(${bean.numTime}) ${bean.author} 初版。
	 */
	@SuppressWarnings("unused")
	private static String verNum = "V100(${bean.numTime})";// 版本号

	/**
	 * 查询  ${detail.subName} 数据
	 * 
	 * 
	 * @date ${bean.dayTime}
	 * 
	 * @param loginInfoObj  登录信息
	 * @param bizDataMap  提交参数
	 * @return
	 */
	public Map<String, Object> get${detail.javaFlieName}Info(LoginInfoObj loginInfoObj, Map<String, String> bizDataMap) {
		// =================================================
		return get${detail.javaFlieName}Info(loginInfoObj, bizDataMap, null);
	}


	/**
	 * 查询  ${detail.subName} 数据
	 * 
	 * 
	 * @date ${bean.dayTime}
	 * 
	 * @param loginInfoObj  登录信息
	 * @param bizDataMap  提交参数
	 * @return
	 */
	public Map<String, Object> get${detail.javaFlieName}Info(LoginInfoObj loginInfoObj, Map<String, String> bizDataMap,
			String otherReturnFields) {
		// ===========================================================
		List<Object> paramObjectsList = new ArrayList<Object>();

		StringBuffer sqlBuff = new StringBuffer(50);
		sqlBuff.append("SELECT h1.organizationId,h1.oprSeqFlag ");
		if (otherReturnFields != null && otherReturnFields.trim().length() > 0) {
			sqlBuff.append(",");
			sqlBuff.append(otherReturnFields);
		}
		sqlBuff.append(" FROM ").append(${detail.javaFlieName}CVal.${(detail.tableName)?upper_case}).append(" h1 ");
		sqlBuff.append("WHERE h1.organizationId = ? ");
		paramObjectsList.add(bizDataMap.get(${detail.javaFlieName}CVal.KEYNAME_ORGANIZATIONID));
		sqlBuff.append("AND h1.${detail.pk02} = ? ");
		paramObjectsList.add(bizDataMap.get(${detail.javaFlieName}CVal.KEYNAME_${(detail.pk02)?upper_case}));
		try {
			Map<String, Object> rsData = queryForMap(loginInfoObj, sqlBuff.toString(), paramObjectsList, false);
			return rsData;
		} catch (EmptyResultDataAccessException err1) {
			// 执行成功，但是没有对应的记录。
		} // 其它异常，比如语法异常等，抛给上层处理。
		return null;
	}


	<#if (detail.systemCodeList)?size !=0>
	/**
	* 查询  系统代码 数据
	*
	*
	* @date ${bean.dayTime}
	*
	* @param loginInfoObj  登录信息
	* @param bizDataMap  提交参数
	* @return
	*/
	public Map<String, Object> getSystemCodeInfo(LoginInfoObj loginInfoObj, Map<String, String> bizDataMap,
	String codeId,String codeType) {
	// ===========================================================
		List<Object> paramObjectsList = new ArrayList<Object>();

		StringBuffer sqlBuff = new StringBuffer(50);
		sqlBuff.append("SELECT h1.codeId");

		sqlBuff.append(" FROM ").append(${detail.javaFlieName}CVal.TB_BSM_CODE_ML).append(" h1 ");

		sqlBuff.append("WHERE h1.organizationId = ? ");
		paramObjectsList.add(bizDataMap.get(${detail.javaFlieName}CVal.KEYNAME_ORGANIZATIONID));
		sqlBuff.append("AND h1.codeId = ? ");
		paramObjectsList.add(codeId.trim());
		sqlBuff.append("AND h1.languageId = ? ");
		paramObjectsList.add(loginInfoObj.getLanguage());
		sqlBuff.append("AND h1.codeType = ? ");
		paramObjectsList.add(codeType);

		try {
		Map<String, Object> rsData = queryForMap(loginInfoObj, sqlBuff.toString(), paramObjectsList, false);
		//System.out.println(rsData);
		return rsData;
		} catch (EmptyResultDataAccessException err1) {
		// 执行成功，但是没有对应的记录。
		} // 其它异常，比如语法异常等，抛给上层处理。
		return null;
	}
	</#if>
	<#if (detail.otherCodeList)?size !=0>
	<#list (detail.otherCodeList) as otherTable>
	/**
	* 查询  ${otherTable.codeName} 数据
	*
	* @author ${bean.author}
	*
	* @date ${bean.dayTime}
	*
	* @param loginInfoObj
	* @param bizDataMap
	* @param otherReturnFields
	* @return
	*/
	public Map<String, Object> get${(otherTable.codeName)?cap_first}DataInfo(LoginInfoObj loginInfoObj, Map<String, String> bizDataMap,
	String otherReturnFields) {
	// ===========================================================
		List<Object> paramObjectsList = new ArrayList<Object>();

		StringBuffer sqlBuff = new StringBuffer(50);
		sqlBuff.append("SELECT h1.organizationId, h1.${otherTable.tableId} ");
		if (otherReturnFields != null && otherReturnFields.trim().length() > 0) {
			sqlBuff.append(",");
			sqlBuff.append(otherReturnFields);
		}
		sqlBuff.append(" FROM ").append(${detail.javaFlieName}CVal.TB_${(otherTable.tableName)}).append(" h1 ");

		sqlBuff.append("WHERE h1.organizationId = ? ");
		paramObjectsList.add(bizDataMap.get(${detail.javaFlieName}CVal.KEYNAME_ORGANIZATIONID));
		sqlBuff.append("AND h1.${otherTable.tableId} = ? ");
		paramObjectsList.add(bizDataMap.get(${detail.javaFlieName}CVal.KEYNAME_${(otherTable.tableId)?upper_case}));

		try {
			Map<String, Object> rsData = queryForMap(loginInfoObj, sqlBuff.toString(), paramObjectsList, false);
			//System.out.println(rsData);
		return rsData;
		} catch (EmptyResultDataAccessException err1) {
			// 执行成功，但是没有对应的记录。
		} // 其它异常，比如语法异常等，抛给上层处理。
		return null;
	}
	</#list>
	</#if>
}
